clear all
set more off
set matsize 10000
set maxvar 15000

cd "/Users/edson/Dropbox/Electricity_CLS/Canary_Codes_Data"
*When running these codes, please change the directory to
*whatever folder the data and codes have been saved.
*Also, create four subfolders within the main folder: 
*"data," "dofiles," "logfiles," and "graphs" – 
*this is crucial to run the codes smoothly.
*Make sure all the .dta datasets are saved in the
*subfolder "data," and the dofile is saved in the 
*subfolder "dofiles." The output will be saved in 
*the subfolder "logfiles," and the figures in the
*subfolder "graphs." Finally, create a subfolder 
*in the "data" subfolder named “eventstudy.”

capture log close
log using logfiles/Canary_logfile.log, replace

clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

label var state_fips "State FIPS"
label var county_fips "County FIPS"
label var plant_id "Power Plant ID"
label var idcountyplant "ID for a plant-county pair"
label var year "Year"
label var cinityropr "Power plant initial year of operation"
label var imr "Infant mortality rate (per 1,000 live births)"
label var lnimr "log(infant mortality rate)"
label var births_rs "Number of births by county of residence"
label var ccapacity "Coal-fired electricity generating capacity"
label var f_coalq "Coal consumption in electricity generation (in 1,000 tons)"
label var generation "Net electricity generation (million kilowatt-hours)"
label var cap30mile_hydro "Hydroelectric capacity within 30 miles of county centroid (in 100s of MW)"
label var scap1940  "Dummy for BELOW median coal generating capacity in 1940"
label var bcap1940  "Dummy for ABOVE median coal generating capacity in 1940"
label var laty "Country centroid latitude"
label var lony "Country centroid longitude"
label var yprcp "Total precipitation (in millimeters)"
label var ytav "Average temperature (in degrees Celsius)"
label var yddb10 "Degree days below 10 degrees Celsius"
label var ydda29 "Degree days above 29 degrees Celsius"
label var dist_miles "Distance between power plant and county centroid"
label var dist0_10 "Distance between power plant and county centroid -- 0-10 miles"
label var dist10_20 "Distance between power plant and county centroid -- 10-20 miles"
label var dist20_30 "Distance between power plant and county centroid -- 20-30 miles"
label var dist30_40 "Distance between power plant and county centroid -- 30-40 miles"
label var dist40_50 "Distance between power plant and county centroid -- 40-50 miles"
label var dist50_60 "Distance between power plant and county centroid -- 50-60 miles"
label var dist60_70 "Distance between power plant and county centroid -- 60-70 miles"
label var dist70_80 "Distance between power plant and county centroid -- 70-80 miles"
label var dist80_90 "Distance between power plant and county centroid -- 80-90 miles"
label var sulf "Sulfates (in 1000s ug/m-3) based on our coal consumption & AP3 model"
label var pop "Population"
label var pop1940 "Population in 1940"
label var lnpop1940 "log(population in 1940)"
label var popf15_44 "Female population age 15-44"
label var spopurb "Share of urban population"
label var emp "Total employment"
label var emp1940 "Total employment in 1940"
label var lnemp1940 "log(total employment in 1940)"
label var mfg "Manufacturing employment"
label var smfg "Share of manufacturing employment"
label var mfg1940 "Manufacturing employment in 1940"
label var lnmfg1940 "log(Manufacturing employment in 1940)"
label var light "Share of households with electric lighting"
label var light1940 "Share of households with electric lighting in 1940"
label var railroads "Railroad mileage within county in 1911"
label var inst1944  "Predicted interstate highway from 1944 plan"
label var control "County 30-90 miles from power plants"
label var treat "County 0-30 miles from a power plant"
label var post "Power plant operating"
label var treatpost "Interaction treat x post"
label var sc40treatpost "Interaction treatpost x BELOW median coal generating capacity in 1940"
label var bc40treatpost "Interaction treatpost x ABOVE median coal generating capacity in 1940"
label var ltreatpost "Interaction treatpost x BELOW median household electricity access in 1940"
label var htreatpost "Interaction treatpost x ABOVE median household electricity access in 1940"
label var streatpost "Interaction treatpost x SMALL Plant (< 75MW)"
label var btreatpost "Interaction treatpost x LARGE Plant (≥ 75MW)"
label var treatdown_post "Interaction treatpost x DOWNWIND (90◦arc from plant centroid)"
label var treatup_post "Interaction treatpost x UPWIND (270◦arc from plant centroid)"
label var treat20post "treatpost w/ alternative treat 0-20 miles from a power plant"
label var sc40treat20post "Interaction treat20post x BELOW median coal generating capacity in 1940"
label var bc40treat20post "Interaction treat20post x ABOVE median coal generating capacity in 1940"
label var ltreat20post "Interaction treat20post x BELOW median household electricity access in 1940"
label var htreat20post "Interaction treat20post x ABOVE median household electricity access in 1940"
label var treat40post "treatpost w/ alternative treat 0-40 miles from a power plant"
label var sc40treat40post "Interaction treat40post x BELOW median coal generating capacity in 1940"
label var bc40treat40post "Interaction treat40post x ABOVE median coal generating capacity in 1940"
label var ltreat40post "Interaction treat40post x BELOW median household electricity access in 1940"
label var htreat40post "Interaction treat40post x ABOVE median household electricity access in 1940"
label var treat60post "treatpost w/ alternative treat 0-60 miles from a power plant"
label var treat60postsulf "Interation treat60post x sulf"
label var evtime "Year - Power plant initial year of operation"
label var evtimet11b "11 years before plant opening"
label var evtimet10b "10 years before plant opening"
label var evtimet9b "9 years before plant opening"
label var evtimet8b "8 years before plant opening"
label var evtimet7b "7 years before plant opening"
label var evtimet6b "6 years before plant opening"
label var evtimet5b "5 years before plant opening"
label var evtimet4b "4 years before plant opening"
label var evtimet3b "3 years before plant opening"
label var evtimet2b "2 years before plant opening"
label var evtimet1b "1 year before plant opening"
label var evtimet0 "Year power plant starts operation"
label var evtimet1a "1 year after plant opening"
label var evtimet2a "2 years after plant opening"
label var evtimet3a "3 years after plant opening"
label var evtimet4a "4 years after plant opening"
label var evtimet5a "5 years after plant opening"
label var evtimet6a "5 years after plant opening"
label var evtimet7a "7 years after plant opening"
label var sc40evtimet0 "Interaction evtimet0 x BELOW median coal generating capacity in 1940"
label var sc40evtimet1a "Interaction evtimet1a x BELOW median coal generating capacity in 1940"
label var sc40evtimet2a "Interaction evtimet2a x BELOW median coal generating capacity in 1940"
label var sc40evtimet3a "Interaction evtimet3a x BELOW median coal generating capacity in 1940"
label var sc40evtimet4a "Interaction evtimet4a x BELOW median coal generating capacity in 1940"
label var sc40evtimet5a "Interaction evtimet5a x BELOW median coal generating capacity in 1940"
label var sc40evtimet6a "Interaction evtimet6a x BELOW median coal generating capacity in 1940"
label var sc40evtimet7a "Interaction evtimet7a x BELOW median coal generating capacity in 1940"
label var bc40evtimet0 "Interaction evtimet0 x ABOVE median coal generating capacity in 1940"
label var bc40evtimet1a "Interaction evtimet1a x ABOVE median coal generating capacity in 1940"
label var bc40evtimet2a "Interaction evtimet2a x ABOVE median coal generating capacity in 1940"
label var bc40evtimet3a "Interaction evtimet3a x ABOVE median coal generating capacity in 1940"
label var bc40evtimet4a "Interaction evtimet4a x ABOVE median coal generating capacity in 1940"
label var bc40evtimet5a "Interaction evtimet5a x ABOVE median coal generating capacity in 1940"
label var bc40evtimet6a "Interaction evtimet6a x ABOVE median coal generating capacity in 1940"
label var bc40evtimet7a "Interaction evtimet7a x ABOVE median coal generating capacity in 1940"
label var levtimet0 "Interaction evtimet0 x BELOW median household electricity access in 1940"
label var levtimet1a "Interaction evtimet1a x BELOW median household electricity access in 1940"
label var levtimet2a "Interaction evtimet2a x BELOW median household electricity access in 1940"
label var levtimet3a "Interaction evtimet3a x BELOW median household electricity access in 1940"
label var levtimet4a "Interaction evtimet4a x BELOW median household electricity access in 1940"
label var levtimet5a "Interaction evtimet5a x BELOW median household electricity access in 1940"
label var levtimet6a "Interaction evtimet6a x BELOW median household electricity access in 1940"
label var levtimet7a "Interaction evtimet7a x BELOW median household electricity access in 1940"
label var hevtimet0 "Interaction evtimet0 x ABOVE median household electricity access in 1940"
label var hevtimet1a "Interaction evtimet1a x ABOVE median household electricity access in 1940"
label var hevtimet2a "Interaction evtimet2a x ABOVE median household electricity access in 1940"
label var hevtimet3a "Interaction evtimet3a x ABOVE median household electricity access in 1940"
label var hevtimet4a "Interaction evtimet4a x ABOVE median household electricity access in 1940"
label var hevtimet5a "Interaction evtimet5a x ABOVE median household electricity access in 1940"
label var hevtimet6a "Interaction evtimet6a x ABOVE median household electricity access in 1940"
label var hevtimet7a "Interaction evtimet7a x ABOVE median household electricity access in 1940"

keep state_fips county_fips plant_id idcountyplant year cinityropr /*
*/ imr lnimr births_rs ccapacity f_coalq generation cap30mile_hydro scap1940 bcap1940 /*
*/ laty lony yprcp ytav yddb10 ydda29 /*
*/ dist_miles dist0_10 dist10_20 dist20_30 dist30_40 /*
*/ dist40_50 dist50_60 dist60_70 dist70_80 dist80_90 /*
*/ sulf pop pop1940 lnpop1940 popf15_44 spopurb /*
*/ emp emp1940 lnemp1940 mfg smfg mfg1940 lnmfg1940 /*
*/ light light1940 railroads inst1944 /*
*/ control treat post treatpost sc40treatpost bc40treatpost /*
*/ ltreatpost htreatpost streatpost btreatpost /*
*/ treatdown_post treatup_post treat20post sc40treat20post /*
*/ bc40treat20post ltreat20post htreat20post /*
*/ treat40post sc40treat40post bc40treat40post /*
*/ ltreat40post htreat40post treat60post treat60postsulf /*
*/ evtime evtimet11b evtimet10b evtimet9b evtimet8b /*
*/ evtimet7b evtimet6b evtimet5b evtimet4b evtimet3b /*
*/ evtimet2b evtimet1b evtimet0 evtimet1a evtimet2a /*
*/ evtimet3a evtimet4a evtimet5a evtimet6a evtimet7a /*
*/ sc40evtimet0 sc40evtimet1a sc40evtimet2a sc40evtimet3a /*
*/ sc40evtimet4a sc40evtimet5a sc40evtimet6a sc40evtimet7a /*
*/ bc40evtimet0 bc40evtimet1a bc40evtimet2a bc40evtimet3a /*
*/ bc40evtimet4a bc40evtimet5a bc40evtimet6a bc40evtimet7a /*
*/ levtimet0 levtimet1a levtimet2a levtimet3a levtimet4a /*
*/ levtimet5a levtimet6a levtimet7a hevtimet0 hevtimet1a /*
*/ hevtimet2a hevtimet3a hevtimet4a hevtimet5a hevtimet6a /*
*/ hevtimet7a 

order state_fips county_fips plant_id idcountyplant year cinityropr /*
*/ imr lnimr births_rs ccapacity f_coalq generation cap30mile_hydro scap1940 bcap1940 /*
*/ laty lony yprcp ytav yddb10 ydda29 /*
*/ dist_miles dist0_10 dist10_20 dist20_30 dist30_40 /*
*/ dist40_50 dist50_60 dist60_70 dist70_80 dist80_90 /*
*/ sulf pop pop1940 lnpop1940 popf15_44 spopurb /*
*/ emp emp1940 lnemp1940 mfg smfg mfg1940 lnmfg1940 /*
*/ light light1940 railroads inst1944 /*
*/ control treat post treatpost sc40treatpost bc40treatpost /*
*/ ltreatpost htreatpost streatpost btreatpost /*
*/ treatdown_post treatup_post treat20post sc40treat20post /*
*/ bc40treat20post ltreat20post htreat20post /*
*/ treat40post sc40treat40post bc40treat40post /*
*/ ltreat40post htreat40post treat60post treat60postsulf /*
*/ evtime evtimet11b evtimet10b evtimet9b evtimet8b /*
*/ evtimet7b evtimet6b evtimet5b evtimet4b evtimet3b /*
*/ evtimet2b evtimet1b evtimet0 evtimet1a evtimet2a /*
*/ evtimet3a evtimet4a evtimet5a evtimet6a evtimet7a /*
*/ sc40evtimet0 sc40evtimet1a sc40evtimet2a sc40evtimet3a /*
*/ sc40evtimet4a sc40evtimet5a sc40evtimet6a sc40evtimet7a /*
*/ bc40evtimet0 bc40evtimet1a bc40evtimet2a bc40evtimet3a /*
*/ bc40evtimet4a bc40evtimet5a bc40evtimet6a bc40evtimet7a /*
*/ levtimet0 levtimet1a levtimet2a levtimet3a levtimet4a /*
*/ levtimet5a levtimet6a levtimet7a hevtimet0 hevtimet1a /*
*/ hevtimet2a hevtimet3a hevtimet4a hevtimet5a hevtimet6a /*
*/ hevtimet7a  

compress
save data/eventstudy_treat30miles_90_11_7.dta, replace


clear all
use data/imr_final_balanced.dta, clear

label var state_fips "State FIPS"
label var county_fips "County FIPS"
label var year "Year"
label var imr "Infant mortality rate (per 1,000 live births)"
label var lnimr "log(infant mortality rate)"
label var dimr "Infant mortality rate - change 1940-1930"
label var births_rs "Number of births by county of residence"
label var deaths_under_1yr "Number of infant deaths by county of residence"
label var cap30mile "Coal-fired generating capacity within 30 miles of county centroid (100s of MW)"
label var cap30mile_1962 "Coal-fired capacity within 30 miles of county centroid (100s of MW) in 1962"
label var dcap30mile62_38 "Coal capacity within 30 miles of county centroid (100s of MW) - change 1962-1938"
label var coal30mile "Coal consumption within 30 miles of county centroid (100K Tons)"
label var cap50mile "Coal-fired generating capacity within 50 miles of county centroid (100s of MW)"
label var cap100mile "Coal-fired generating capacity within 100 miles of county centroid (100s of MW)"
label var cap30mile_hydro "Hydroelectric capacity within 30 miles of county centroid (100s of MW)"
label var cap50mile_hydro "Hydroelectric capacity within 50 miles of county centroid (100s of MW)"
label var scap1940  "Dummy for BELOW median coal generating capacity in 1940"
label var bcap1940  "Dummy for ABOVE median coal generating capacity in 1940"
label var b1950cap30mile "Interaction cap30mile x dummy for BEFORE 1950"
label var a1950cap30mile "Interaction cap30mile x dummy for AFTER 1950"
label var scap1940cap30mile "Interaction cap30mile x BELOW median coal generating capacity in 1940"
label var bcap1940cap30mile "Interaction cap30mile x ABOVE median coal generating capacity in 1940"
label var sc40b50cap30mile "Interaction scap1940cap30mile x dummy for BEFORE 1950"
label var bc40b50cap30mile "Interaction bcap1940cap30mile x dummy for BEFORE 1950"
label var sc40a50cap30mile "Interaction scap1940cap30mile x dummy for AFTER 1950"
label var bc40a50cap30mile "Interaction bcap1940cap30mile x dummy for AFTER 1950"
label var scap1940cap50mile "Interaction cap50mile x BELOW median coal generating capacity in 1940"
label var bcap1940cap50mile "Interaction cap50mile x ABOVE median coal generating capacity in 1940"
label var scap1940cap100mile "Interaction cap100mile x BELOW median coal generating capacity in 1940"
label var bcap1940cap100mile "Interaction cap100mile x ABOVE median coal generating capacity in 1940"
label var cap30mileL2wlight "Interaction cap30mile x BELOW median household electricity access in 1940"
label var cap30mileH2wlight "Interaction cap30mile x ABOVE median household electricity access in 1940"
label var cap50mileL2wlight "Interaction cap50mile x BELOW median household electricity access in 1940"
label var cap50mileH2wlight "Interaction cap50mile x ABOVE median household electricity access in 1940"
label var cap100mileL2wlight "Interaction cap100mile x BELOW median household electricity access in 1940"
label var cap100mileH2wlight "Interaction cap100mile x ABOVE median household electricity access in 1940"
label var amdiarrcap30milelightL2w "Interaction cap30mileL2wlight x ABOVE median infant diarrhea deaths in 1930"
label var cap30mileL2wlightH2wcoalstove  "Interaction cap30mileL2wlight x ABOVE median use of coal cookstoves in 1940"
label var cap30milecapdop10l "Interaction cap30mile x dummy for plant operating for <10 years"
label var cap30milecapdop10m "Interaction cap30mile x dummy for plant operating for ≥10 years"
label var laty "Country centroid latitude"
label var lony "Country centroid longitude"
label var yprcp "Total precipitation (in millimeters)"
label var ytav "Average temperature (in degrees Celsius)"
label var yddb10 "Degree days below 10 degrees Celsius"
label var ydda29 "Degree days above 29 degrees Celsius"
label var lat "Country centroid latitude"
label var lon "Country centroid longitude"
label var yprcpm "Total precipitation (in millimeters) - average of t-4 to t"
label var ytavm "Average temperature (in degrees Celsius) - average of t-4 to t"
label var yddb10m "Degree days below 10 degrees Celsius - average of t-4 to t"
label var ydda29m "Degree days above 29 degrees Celsius - average of t-4 to t"
label var dist30_1960 "Distance between county centroid and power plant of 30MW or larger in 1960"
label var n0 "No. obs before coal plant openings - n0=25: no plant within county in the sample"
label var pop "Population"
label var pop1940 "Population in 1940"
label var lnpop1940 "log(population in 1940)"
label var spopurb "Share of urban population"
label var ppopurb "Percentage of urban population"
label var dppopurb "Percentage of urban population - change 1940-1930"
label var swhite "Share of white population"
label var pwhite "Percentage of white population"
label var dpwhite "Percentage of white population - change 1940-1930"
label var hschool "Share of population 25yo+ with a high school degree"
label var phschool "Percentage of population 25yo+ with a high school degree"
label var emp "Total employment"
label var lnemp "log(total employment)"
label var emp1940 "Total employment in 1940"
label var lnemp1940 "long(total employment in 1940)"
label var dlnemp "log(total employment) - change 1940-1930"
label var mfg "Manufacturing employment"
label var lnmfg "log(manufacturing employment)"
label var smfg "Share of manufacturing employment"
label var pmfg "Percentage of manufacturing employment"
label var dpmfg "Percentage of manufacturing employment - change 1940-1930"
label var mfg1940 "Manufacturing employment in 1940"
label var lnmfg1940 "log(Manufacturing employment in 1940)"
label var dmfg "Manufacturing employment - change 1940-1930"
label var mfgwages_bls90 "Manufacturing payroll per worker (1990 USD)"
label var lnmfgwages_bls90 "log(manufacturing payroll per worker)"
label var dmfgwages_bls90 "Manufacturing payroll per worker (1990 USD) - change 1940-1930"
label var retwages_bls90 "Retail payroll per worker (1990 USD)"
label var lnretwages_bls90 "log(retail payroll per worker)"
label var dretwages_bls90 "Retail payroll per worker (1990 USD) - change 1940-1930"
label var mrhouse_bls90 "Median dwelling rent (1990 USD)"
label var lnmrhouse_bls90 "log(median dwelling rent)"
label var dlnmrhouse_bls90 "Median dwelling value (1990 USD) - change 1940-1930"
label var mvhouse_bls90 "Median dwelling value (1990 USD)"
label var lnmvhouse_bls90 "log(median dwelling value)"
label var dlnmvhouse_bls90 "Median dwelling value (1990 USD) - change 1940-1930"
label var N_mrhouse "Number of obs with information on median dwelling rent"
label var light "Share of households with electric lighting"
label var light1940 "Share of households with electric lighting in 1940"
label var railroads "Railroad mileage within county in 1911 (Donaldson & Hornbeck 2016)"
label var inst1944  "Predicted interstate highway from 1944 plan (Michaels 2008)"
label var farmelec "Percentage of farm households with electricity"
label var runwat "Percentage of households with running water"
label var elecgasstove "Percentage of households with modern (electric + gas) stoves"


keep state_fips county_fips year imr lnimr dimr births_rs deaths_under_1yr /*
*/ cap30mile cap30mile_1962 dcap30mile62_38 coal30mile cap50mile cap100mile /*
*/ cap30mile_hydro cap50mile_hydro scap1940 bcap1940 b1950cap30mile a1950cap30mile /*
*/ scap1940cap30mile bcap1940cap30mile sc40b50cap30mile bc40b50cap30mile /*
*/ sc40a50cap30mile bc40a50cap30mile scap1940cap50mile bcap1940cap50mile /*
*/ scap1940cap100mile bcap1940cap100mile cap30mileL2wlight cap30mileH2wlight /*
*/ cap50mileL2wlight cap50mileH2wlight cap100mileL2wlight cap100mileH2wlight /*
*/ amdiarrcap30milelightL2w cap30mileL2wlightH2wcoalstove /* 
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ laty lony yprcp ytav yddb10 ydda29 /*
*/ lat lon yprcpm ytavm yddb10m ydda29m /*
*/ dist30_1960 n0 pop pop1940 lnpop1940 /*
*/ spopurb ppopurb dppopurb swhite pwhite dpwhite hschool phschool /*
*/ emp lnemp emp1940 lnemp1940 dlnemp mfg lnmfg smfg pmfg dpmfg /*
*/ mfg1940 lnmfg1940 dmfg mfgwages_bls90 lnmfgwages_bls90 /*
*/ dmfgwages_bls90 retwages_bls90 lnretwages_bls90 dretwages_bls90 /*
*/ mrhouse_bls90 lnmrhouse_bls90 dlnmrhouse_bls90 N_mrhouse /*
*/ mvhouse_bls90 lnmvhouse_bls90 dlnmvhouse_bls90 /*
*/ light light1940 railroads inst1944 farmelec runwat elecgasstove

order state_fips county_fips year imr lnimr dimr births_rs deaths_under_1yr /*
*/ cap30mile cap30mile_1962 dcap30mile62_38 coal30mile cap50mile cap100mile /*
*/ cap30mile_hydro cap50mile_hydro scap1940 bcap1940 b1950cap30mile a1950cap30mile /*
*/ scap1940cap30mile bcap1940cap30mile sc40b50cap30mile bc40b50cap30mile /*
*/ sc40a50cap30mile bc40a50cap30mile scap1940cap50mile bcap1940cap50mile /*
*/ scap1940cap100mile bcap1940cap100mile cap30mileL2wlight cap30mileH2wlight /*
*/ cap50mileL2wlight cap50mileH2wlight cap100mileL2wlight cap100mileH2wlight /*
*/ amdiarrcap30milelightL2w cap30mileL2wlightH2wcoalstove /* 
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ laty lony yprcp ytav yddb10 ydda29 /*
*/ lat lon yprcpm ytavm yddb10m ydda29m /*
*/ dist30_1960 n0 pop pop1940 lnpop1940 /*
*/ spopurb ppopurb dppopurb swhite pwhite dpwhite hschool phschool /*
*/ emp lnemp emp1940 lnemp1940 dlnemp mfg lnmfg smfg pmfg dpmfg /*
*/ mfg1940 lnmfg1940 dmfg mfgwages_bls90 lnmfgwages_bls90 /*
*/ dmfgwages_bls90 retwages_bls90 lnretwages_bls90 dretwages_bls90 /*
*/ mrhouse_bls90 lnmrhouse_bls90 dlnmrhouse_bls90 N_mrhouse /*
*/ mvhouse_bls90 lnmvhouse_bls90 dlnmvhouse_bls90 /*
*/ light light1940 railroads inst1944 farmelec runwat elecgasstove

keep if dist30_1960<=90

compress
save data/imr_final_balanced.dta, replace



********************************************************************************
********************************************************************************
***FIGURE 1
********************************************************************************
********************************************************************************

****************************************
***PANEL A
****************************************
clear all
use data/HSUS_Electricity2.dta, clear

keep if (year>=1938 & year<=1962)

sort year 
gen nkilowatts = kilwatts/1000
gen nffkw = ffkw/1000
gen ncoaltons = coaltons/1000
label var nkilowatts "Kilowatt Hours"
label var nffkw "Fossil Fuel Kilowatt Hours"
label var ncoaltons "Tons of Coal"

twoway (line nkilowatt year, sort yaxis(1) lcolor(black) lpattern(solid)) /*
*/ (line nffkw year, sort yaxis(1) lcolor(black) lpattern(dash)) /*
*/ (line ncoaltons year, sort yaxis(2) lcolor(black) lpattern(shortdash)), /*
*/ ytitle("Billions KWH", axis(1)) ylabel(0(200)1000, axis(1)) /*
*/ ytitle("Millions of Short Tons", axis(2)) /*
*/ xtitle("Year") /*
*/ saving(graphs/Fig_1a.gph, replace)
graph export graphs/Fig_1a.pdf, replace

****************************************
***PANEL B
****************************************
clear all
use data/coalbysector.dta, clear

keep if (year>=1938 & year<=1962)

sort year
gen nelectric = electricpower/1000
gen nmanmining = manufactmining/1000
gen nretail = retail/1000
gen nvesselrr = vesselrr/1000

label var nelectric "Electricity"
label var nmanmining "Industrial"
label var nretail "Heating"
label var nvesselrr "Transportation"

twoway (line nelectric year, sort lcolor(black) lpattern(solid)) /*
*/ (line nmanmining year, sort lcolor(black) lpattern(dash_dot)) /*
*/ (line nretail year, sort lcolor(black) lpattern(dash)) /*
*/ (line nvesselrr year, sort lcolor(black) lpattern(shortdash)), /*
*/ ytitle("Millions of Short Tons") xtitle("Year") /*
*/ saving(graphs/Fig_1b.gph, replace)
graph export graphs/Fig_1b.pdf, replace


********************************************************************************
********************************************************************************
***FIGURE 2
********************************************************************************
********************************************************************************
use data/eventstudy_treat30miles_90_11_7.dta, clear

capture drop np
bysort treat plant_id: gen np = _n
tab np if treat==1
*         np |      Freq.     Percent        Cum.
*------------+-----------------------------------
*          1 |        270        1.02        1.02
*number of openings in our sample

capture drop N
bysort county_fips treat: gen N = _N
capture drop np
bysort treat N plant_id: gen np = _n
tab np if treat==1 & N==25
*         np |      Freq.     Percent        Cum.
*------------+-----------------------------------
*          1 |        205        1.58        1.58
*number of openings in which the county affected
*is not affected by other openings


reg sulf dist10_20 dist20_30 dist30_40 dist40_50 dist50_60 dist60_70 dist70_80 dist80_90, cluster(county_fips) 
parmest, saving(data/sulf_dist.dta, replace)


use data/sulf_dist.dta, clear

drop if parm=="_cons"

gen dist = substr(parm,-5,2)
destring dist, replace
replace dist = dist +5
expand 2 if _n==1
replace dist = 5 if _n==9
replace estimate=0 if dist==5
replace min95=0 if dist==5
replace max95=0 if dist==5
sort dist

keep dist estimate min95 max95
order dist estimate min95 max95

twoway (rcap max95 min95 dist, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (connected estimate dist if dist<=25, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimate dist if dist>25, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)), /*
*/ ytitle(Concentration of Sulfates) ylabel(, angle(horizontal)) yscale(titlegap(*-40)) /*
*/ xtitle(Distance to Coal-Fired Power Plant (Miles)) /*
*/ xline(30, lwidth(medthick) lpattern(shortdash) lcolor(red)) xlabel(5 "0-10" 15 "10-20" 25 "20-30" 35 "30-40" 45 "40-50" /*
*/ 55 "50-60" 65 "60-70" 75 "70-80" 85 "80-90", angle(45)) legend(off) /*
*/ saving(graphs/Fig_2.gph, replace)
graph export graphs/Fig_2.pdf, replace


********************************************************************************
********************************************************************************
***FIGURE 3
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

global Geot1 c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econt1 c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

global Econnlnt1 c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ evtimet11b evtimet10b evtimet9b evtimet8b /*
*/ evtimet7b evtimet6b evtimet4b evtimet3b evtimet2b /*
*/ evtimet1b bc40evtimet0 bc40evtimet1a bc40evtimet2a bc40evtimet3a /*
*/ bc40evtimet4a bc40evtimet5a bc40evtimet6a bc40evtimet7a /*
*/ sc40evtimet0 sc40evtimet1a sc40evtimet2a sc40evtimet3a sc40evtimet4a /*
*/ sc40evtimet5a sc40evtimet6a sc40evtimet7a /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips)

parmest, saving(data/eventstudy/parmest_sbc40_treat30miles_90_11_7.dta, replace)


use data/eventstudy/parmest_sbc40_treat30miles_90_11_7.dta, clear

gen var = substr(parm,1,7)
gen var_aux = substr(parm,1,10)
replace var = "bc40evtime" if var=="bc40evt"
replace var = "sc40evtime" if var=="sc40evt"
gen bef_aft = substr(parm,-1,1)

keep if var=="evtimet" |var=="bc40evtime" |var=="sc40evtime"

gen period = substr(parm,-3,2)
gen period_aux = substr(period,-1,1) 
gen period_aux2 = substr(period,-2,1) 
replace period = period_aux if period_aux2=="t"
replace period = "0" if period=="et"
destring period, replace
drop period_aux period_aux2

ren estimate estimatet

keep var period estimatet min95 max95
order var period estimatet min95 max95

replace period = period * (-1) if var=="evtimet"
drop if period==-11 |period==7

expand 2 in 1
replace estimatet = 0 in 24
replace min95 = 0 in 24
replace max95 = 0 in 24
replace period = -5 in 24

sort var period

twoway (rcap max95 min95 period if var=="evtimet" & period>=-10 & period<=0, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (rcap max95 min95 period if var=="bc40evtime" & period>=1 & period<=6, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (connected estimatet period if var=="evtimet" & period<=-5, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="evtimet" & period>=-4 & period<=0, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="bc40evtime" & period>=1, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)), /*
*/ title((b) Above Median Generating Capacity in 1940, size(medlarge)) subtitle(" ", margin(l+0 r+0 b-1 t-1)) /*
*/ ytitle(Infant Mortality Rate Per 1000 Live Births) ylabel(-1(0.5)2,angle(0)) /*
*/ xtitle(Years Relative to Power Plant Opening) /*
*/ xline(-4.5 0.5, lwidth(vthin) lpattern(solid) lcolor(black)) xlabel(-10(1)6) legend(off) /* 
*/ text(-0.3 -3.5 "Construction", place(e) box just(center)) /* 
*/ saving(graphs/eventstudy_treat30miles_90_11_7_bcap1940_wCIrange.gph, replace)

twoway (rcap max95 min95 period if var=="evtimet" & period>=-10 & period<=0, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (rcap max95 min95 period if var=="sc40evtime" & period>=1 & period<=6, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (connected estimatet period if var=="evtimet" & period<=-5, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="evtimet" & period>=-4 & period<=0, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="sc40evtime" & period>=1, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)), /*
*/ title((a) Below Median Generating Capacity in 1940, size(medlarge)) subtitle(" ", margin(l+0 r+0 b-1 t-1)) /*
*/ ytitle(Infant Mortality Rate Per 1000 Live Births) ylabel(-1(0.5)2,angle(0)) /*
*/ xtitle(Years Relative to Power Plant Opening) /*
*/ xline(-4.5 0.5, lwidth(vthin) lpattern(solid) lcolor(black)) xlabel(-10(1)6) legend(off) /*
*/ text(-0.3 -3.5 "Construction", place(e) box just(center)) /* 
*/ saving(graphs/eventstudy_treat30miles_90_11_7_scap1940_wCIrange.gph, replace)

graph combine graphs/eventstudy_treat30miles_90_11_7_scap1940_wCIrange.gph graphs/eventstudy_treat30miles_90_11_7_bcap1940_wCIrange.gph, /*
*/ ycommon xcommon iscale(1) xsize(10) saving(graphs/Fig_3.gph, replace)
graph export graphs/Fig_3.pdf, replace

erase graphs/eventstudy_treat30miles_90_11_7_scap1940_wCIrange.gph
erase graphs/eventstudy_treat30miles_90_11_7_bcap1940_wCIrange.gph


********************************************************************************
********************************************************************************
***FIGURE 4
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

global Geot1 c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econt1 c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

global Econnlnt1 c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treat60post treat60postsulf /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 

*graph on the net effects
pctile pctsulf = sulf if e(sample)==1 [fw=births_rs], nq(20)
gen eff = _b[treat60post] + _b[treat60postsulf] *pctsulf
gen n5 = _n*5
replace n5 = . if n5>=100

*pctile sulf 5
test _b[treat60post] + _b[treat60postsulf] *(.06654741) = 0
*( 1)  treat60post + .0665474*treat60postsulf = 0
*F(  1,  1968) =    4.09
*Prob > F =    0.0432

*pctile sulf 10
test _b[treat60post] + _b[treat60postsulf] *(.12201186) = 0
*( 1)  treat60post + .1220119*treat60postsulf = 0
*F(  1,  1968) =    3.78
*Prob > F =    0.0520

*pctile sulf 15
test _b[treat60post] + _b[treat60postsulf] *(.19098575) = 0
*( 1)  treat60post + .1909858*treat60postsulf = 0
*F(  1,  1968) =    3.39
*Prob > F =    0.0657

*pctile sulf 20
test _b[treat60post] + _b[treat60postsulf] *(.26113662) = 0
*( 1)  treat60post + .2611366*treat60postsulf = 0
*F(  1,  1968) =    3.00
*Prob > F =    0.0833

*pctile sulf 25
test _b[treat60post] + _b[treat60postsulf] *(.32751432) = 0
*( 1)  treat60post + .3275143*treat60postsulf = 0
*F(  1,  1968) =    2.64
*Prob > F =    0.1045

*pctile sulf 75
test _b[treat60post] + _b[treat60postsulf] *(1.7256587) = 0
*( 1)  treat60post + 1.725659*treat60postsulf = 0
*F(  1,  1968) =    1.70
*Prob > F =    0.1924

*pctile sulf 80
test _b[treat60post] + _b[treat60postsulf] *(2.107451) = 0
*( 1)  treat60post + 2.107451*treat60postsulf = 0
*F(  1,  1968) =    4.00
*Prob > F =    0.0456

*pctile sulf 85
test _b[treat60post] + _b[treat60postsulf] *(2.5201075) = 0
*( 1)  treat60post + 2.520107*treat60postsulf = 0
*F(  1,  1968) =    6.64
*Prob > F =    0.0100

*pctile sulf 90
test _b[treat60post] + _b[treat60postsulf] *(3.2171175) = 0
*( 1)  treat60post + 3.217118*treat60postsulf = 0
*F(  1,  1968) =   10.27
*Prob > F =    0.0014

*pctile sulf 95
test _b[treat60post] + _b[treat60postsulf] *(4.0796723) = 0
*( 1)  treat60post + 4.079672*treat60postsulf = 0
*F(  1,  1968) =   13.01
*Prob > F =    0.0003

twoway (connected eff n5, sort lcolor(black) lwidth(medthin) lpattern(solid) mcolor(black) msize(medium) msymbol(circle_hollow)) /*
*/ (connected eff n5 if n5<=20, sort lcolor(black) lwidth(medthin) lpattern(solid) mcolor(black) msize(medium) msymbol(circle)) /*
*/ (connected eff n5 if n5>=80, sort lcolor(black) lwidth(medthin) lpattern(solid) mcolor(black) msize(medium) msymbol(circle)), /*
*/ ytitle(Estimated Net Effects of Plant Openings) ylabel(-.4(.2)1.4, angle(360)) /*
*/ yline(0, lwidth(medthick) lpattern(shortdash) lcolor(red)) /*
*/ xtitle(Percentiles of Air Pollution Concentration From Power Plants) xlabel(5(5)95) legend(off) /*
*/ saving(graphs/Fig4.gph, replace)
graph export graphs/Fig4.pdf, replace


********************************************************************************
********************************************************************************
***APPENDIX FIGURE A.1
********************************************************************************
********************************************************************************
*reproduction from Hales (1976), as mentioned in the notes of the figure


********************************************************************************
********************************************************************************
***APPENDIX FIGURE A.2
********************************************************************************
********************************************************************************
*schematic graph made in power point


********************************************************************************
********************************************************************************
***APPENDIX FIGURE A.3
********************************************************************************
********************************************************************************
clear all
use data/imr_final_balanced.dta, clear

collapse (sum) births_rs deaths_under_1yr, by(scap1940 year)
gen imr = (deaths_under_1yr/births_rs)*1000

twoway (connected imr year if scap1940==1, sort lcolor(black) lwidth(medthin) /*
*/ lpattern(shortdash) mcolor(black) msize(medsmall) msymbol(circle_hollow)) /*
*/ (connected imr year if scap1940==0, sort lcolor(black) lwidth(medthin) /*
*/ lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)), /*
*/ ytitle(Infant Mortality Rate per 1000 Live Births) ylabel(25(2)49, angle(ninty)) /*
*/ xtitle("")  xlabel(1938(2)1962, angle(forty_five)) /*
*/ legend(order(1 "Below Median" 2 "Above Median") rows(1) size(3)) /*
*/ saving(graphs/AFig_A3.gph, replace)
graph export graphs/AFig_A3.pdf, replace


********************************************************************************
********************************************************************************
***APPENDIX FIGURE A.4
********************************************************************************
********************************************************************************
use data/eventstudy_treat30miles_90_11_7.dta, clear

capture drop n
bysort county_fips: gen n = _n
keep if n==1

keep county_fips treat
save data/sample_counties_DID_30miles_90.dta, replace
*use this dataset as input to create the map in the software ArcGIS


********************************************************************************
********************************************************************************
***APPENDIX FIGURE A.5
********************************************************************************
********************************************************************************

****************************************
***PANEL A
****************************************
clear all
use data/imr_final_balanced.dta, clear

*intermediate steps
sort county_fips year
bysort county_fips: gen dcap30mile = cap30mile - cap30mile[_n-1]
replace dcap30mile = 0 if dcap30mile==.

replace dcap30mile = dcap30mile *100
*coal capacity was measured in 100s of MW, now in MW

sort county_fips year
bysort county_fips: gen opening = (dcap30mile>0 & cap30mile[_n-1]==0)

sort county_fips year
bysort county_fips: gen upgrade = (dcap30mile>0 & cap30mile[_n-1]>0)

gen dcap30mileop_aux = dcap30mile if opening==1
sort county_fips year
bysort county_fips: gen dcap30mileop = sum(dcap30mileop_aux)
drop dcap30mileop_aux
replace dcap30mileop = dcap30mileop/1000
*from megawatt (MW) to gigawatt (GW)

gen dcap30mileup_aux = dcap30mile if upgrade==1
sort county_fips year
bysort county_fips: gen dcap30mileup = sum(dcap30mileup_aux)
drop dcap30mileup_aux
replace dcap30mileup = dcap30mileup/1000
*from megawatt (MW) to gigawatt (GW)

collapse (sum) dcap30mileop (sum) dcap30mileup, by(year)

label var dcap30mileop "Openings" 
label var dcap30mileup "Upgrades"


twoway (area dcap30mileup year if year>=1938, sort fcolor(gray) lcolor(gray)) /*
*/ (area dcap30mileop year if year>=1938, sort fcolor(black) lcolor(black)), /*
*/ ytitle(Coal-Fired Generating Capacity (GW)) ylabel(, angle(horizontal)) /*
*/ xtitle("") xlabel(1938(2)1962, angle(forty_five)) /*
*/ legend(rows(1) order(2 "Openings" 1 "Upgrades")) /*
*/ saving(graphs/AFig_A5a.gph, replace) 
graph export graphs/AFig_A5a.pdf, replace


****************************************
***PANEL B
****************************************
clear all
use data/imr_final_balanced.dta, clear

*intermediate steps
sort county_fips year
bysort county_fips: gen dcap30mile = cap30mile - cap30mile[_n-1]
replace dcap30mile = 0 if dcap30mile==.

replace dcap30mile = dcap30mile *100
*coal capacity was measured in 100s of MW, now in MW

sort county_fips year
bysort county_fips: gen opening = (dcap30mile>0 & cap30mile[_n-1]==0)

sort county_fips year
bysort county_fips: gen upgrade = (dcap30mile>0 & cap30mile[_n-1]>0)


*histogram - openings
histogram dcap30mile if opening==1 & dcap30mile >=50, /*
*/ frequency fcolor(black) lcolor(black) ylabel(, angle(0)) xlabel(0(200)1400) /*
*/ ytitle(Number of Openings) xtitle(Coal Capacity at Opening (MW)) /*
*/ saving(graphs/histogram_openings50mwabove_number.gph, replace)

*histogram - upgrades
histogram dcap30mile if upgrade==1 & dcap30mile >=50, /*
*/ frequency fcolor(gray) lcolor(gray) ylabel(0(200)800, angle(0)) xlabel(0(200)1400) /*
*/ ytitle(Number of Upgrades) xtitle(Increased Coal Capacity (MW)) /*
*/ saving(graphs/histogram_upgrades50mwabove_number.gph, replace)

graph combine /*
*/ graphs/histogram_openings50mwabove_number.gph /*
*/ graphs/histogram_upgrades50mwabove_number.gph, /*
*/ col(1) xcommon saving(graphs/AFig_A5b.gph, replace)
graph export graphs/AFig_A5b.pdf, replace

erase graphs/histogram_openings50mwabove_number.gph
erase graphs/histogram_upgrades50mwabove_number.gph


********************************************************************************
********************************************************************************
***APPENDIX FIGURE A.6
********************************************************************************
********************************************************************************
clear all
use data/imr_final_balanced.dta, clear

keep if year==1962

replace dcap30mile62_38 = dcap30mile62_38 *100
*coal capacity was measured in 100s of MW, now in MW

keep county_fips dcap30mile62_38
save data/sample_coal_counties.dta, replace
*use this dataset as input to create the map in the software ArcGIS


********************************************************************************
********************************************************************************
***APPENDIX FIGURE A.7
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

global Geot1 c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econt1 c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

global Econnlnt1 c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ evtimet11b evtimet10b evtimet9b evtimet8b /*
*/ evtimet7b evtimet6b evtimet4b evtimet3b evtimet2b /*
*/ evtimet1b evtimet0 evtimet1a evtimet2a evtimet3a /*
*/ evtimet4a evtimet5a evtimet6a evtimet7a /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips)

parmest, saving(data/eventstudy/parmest_treat30miles_90_11_7.dta, replace)


use data/eventstudy/parmest_treat30miles_90_11_7.dta, clear

gen var = substr(parm,1,7)
gen bef_aft = substr(parm,-1,1)

keep if var=="evtimet"

gen period = substr(parm,-3,2)
gen period_aux = substr(period,-1,1) 
gen period_aux2 = substr(period,-2,1) 
replace period = period_aux if period_aux2=="t"
replace period = "0" if period=="et"
destring period, replace
drop period_aux period_aux2

replace period = period * (-1) if bef_aft~="a"
drop if period==-11 |period==7

ren estimate estimatet

keep var period estimatet min95 max95
order var period estimatet min95 max95

expand 2 in 1
replace estimatet = 0 in 17
replace min95 = 0 in 17
replace max95 = 0 in 17
replace period = -5 in 17

sort var period

twoway (rcap max95 min95 period if var=="evtimet" & period>=-11 & period<=6, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (connected estimatet period if var=="evtimet" & period<=-5, sort lcolor(black) lwidth(medthin) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="evtimet" & period>=-4 & period<=0, sort lcolor(black) lwidth(medthin) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="evtimet" & period>=1, sort lcolor(black) lwidth(medthin) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)), /*
*/ ytitle(Infant Mortality Rate Per 1000 Live Births) ylabel(,angle(0)) /*
*/ xtitle(Years Relative to Power Plant Opening) /*
*/ xline(-4.5 0.5, lwidth(vthin) lpattern(solid) lcolor(black)) xlabel(-10(1)6) legend(off) /*
*/ text(-0.3 -3.5 "Construction", place(e) box just(center)) /* 
*/ saving(graphs/AFig_A7.gph, replace)
graph export graphs/AFig_A7.pdf, replace


********************************************************************************
********************************************************************************
***APPENDIX FIGURE A.8
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

global Geot1 c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econt1 c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

global Econnlnt1 c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ evtimet11b evtimet10b evtimet9b evtimet8b /*
*/ evtimet7b evtimet6b evtimet4b evtimet3b evtimet2b /*
*/ evtimet1b hevtimet0 hevtimet1a hevtimet2a hevtimet3a /*
*/ hevtimet4a hevtimet5a hevtimet6a hevtimet7a /*
*/ levtimet0 levtimet1a levtimet2a levtimet3a levtimet4a /*
*/ levtimet5a levtimet6a levtimet7a /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips)

parmest, saving(data/eventstudy/parmest_hl_treat30miles_90_11_7.dta, replace)


use data/eventstudy/parmest_hl_treat30miles_90_11_7.dta, clear

gen var = substr(parm,1,7)
gen bef_aft = substr(parm,-1,1)

keep if var=="evtimet" |var=="hevtime" |var=="levtime"

gen period = substr(parm,-3,2)
gen period_aux = substr(period,-1,1) 
gen period_aux2 = substr(period,-2,1) 
replace period = period_aux if period_aux2=="t"
replace period = "0" if period=="et"
destring period, replace
drop period_aux period_aux2

ren estimate estimatet

keep var period estimatet min95 max95
order var period estimatet min95 max95

replace period = period * (-1) if var=="evtimet"
drop if period==-11 |period==7

expand 2 in 1
replace estimatet = 0 in 24
replace min95 = 0 in 24
replace max95 = 0 in 24
replace period = -5 in 24

sort var period

twoway (rcap max95 min95 period if var=="evtimet" & period>=-10 & period<=0, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (rcap max95 min95 period if var=="hevtime" & period>=1 & period<=6, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (connected estimatet period if var=="evtimet" & period<=-5, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="evtimet" & period>=-4 & period<=0, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="hevtime" & period>=1, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)), /*
*/ title((b) Above Median % Households w/ Electricity Access in 1940, size(medlarge)) subtitle(" ", margin(l+0 r+0 b-1 t-1)) /*
*/ ytitle(Infant Mortality Rate Per 1000 Live Births) ylabel(-1(0.5)2,angle(0)) /*
*/ xtitle(Years Relative to Power Plant Opening) /*
*/ xline(-4.5 0.5, lwidth(vthin) lpattern(solid) lcolor(black)) xlabel(-10(1)6) legend(off) /* 
*/ text(-0.3 -3.5 "Construction", place(e) box just(center)) /* 
*/ saving(graphs/eventstudy_treat30miles_90_11_7_Hlight_wCIrange.gph, replace)

twoway (rcap max95 min95 period if var=="evtimet" & period>=-10 & period<=0, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (rcap max95 min95 period if var=="levtime" & period>=1 & period<=6, sort msize(1) lcolor(black) lwidth(vthin) lpattern(shortdash)) /*
*/ (connected estimatet period if var=="evtimet" & period<=-5, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="evtimet" & period>=-4 & period<=0, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)) /*
*/ (connected estimatet period if var=="levtime" & period>=1, sort lcolor(black) lwidth(medium) lpattern(solid) mcolor(black) msize(medsmall) msymbol(circle)), /*
*/ title((a) Below Median % Households w/ Electricity Access in 1940, size(medlarge)) subtitle(" ", margin(l+0 r+0 b-1 t-1)) /*
*/ ytitle(Infant Mortality Rate Per 1000 Live Births) ylabel(-1(0.5)2,angle(0)) /*
*/ xtitle(Years Relative to Power Plant Opening) /*
*/ xline(-4.5 0.5, lwidth(vthin) lpattern(solid) lcolor(black)) xlabel(-10(1)6) legend(off) /*
*/ text(-0.3 -3.5 "Construction", place(e) box just(center)) /* 
*/ saving(graphs/eventstudy_treat30miles_90_11_7_Llight_wCIrange.gph, replace)

graph combine graphs/eventstudy_treat30miles_90_11_7_Llight_wCIrange.gph graphs/eventstudy_treat30miles_90_11_7_Hlight_wCIrange.gph, /*
*/ ycommon xcommon iscale(1) xsize(10) saving(graphs/AFig_A8.gph, replace)
graph export graphs/AFig_A8.pdf, replace

erase graphs/eventstudy_treat30miles_90_11_7_Llight_wCIrange.gph 
erase graphs/eventstudy_treat30miles_90_11_7_Hlight_wCIrange.gph


********************************************************************************
********************************************************************************
***APPENDIX FIGURE A.9
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

collapse ccapacity f_coalq [fw=births_rs], by(evtime)
drop if evtime==-7 | evtime==7

replace f_coalq = 0 if f_coalq==.
replace f_coalq = f_coalq/100
*coal measured in 100,000 tons

expand 2 if evtime<0

sort evtime

twoway (connected ccapacity evtime if evtime<=-1, sort yaxis(1) lcolor(black) lwidth(medthin) lpattern(solid) mcolor(black) msize(medsmall) msymbol(square_hollow)) /*
*/ (connected ccapacity evtime if evtime>=0, sort yaxis(1) lcolor(black) lwidth(medthin) lpattern(solid) mcolor(black) msize(medsmall) msymbol(square_hollow)) /*
*/ (connected f_coalq evtime if evtime<=-1, sort yaxis(2) lcolor(black) lwidth(medthin) lpattern(shortdash) mcolor(black) msize(medsmall) msymbol(triangle_hollow)) /*
*/ (connected f_coalq evtime if evtime>=0, sort yaxis(2) lcolor(black) lwidth(medthin) lpattern(shortdash) mcolor(black) msize(medsmall) msymbol(triangle_hollow)), /*
*/ ytitle("Coal-Fired Generating Capacity (MW)", axis(1)) ylabel(0(50)300, axis(1) angle(ninty)) /*
*/ ytitle("Coal Consumption (100,000 tons)", axis(2)) ylabel(0(1)8, axis(2) angle(ninty)) /*
*/ xtitle(Years Relative to Power Plant Openings) /*
*/ xline(-0.5, lwidth(thin) lpattern(shortdash) lcolor(black)) xlabel(-6(1)6) /*
*/ legend(order(1 "Capacity" 3 "Consumption") rows(1) size(3.5)) /*
*/ saving(graphs/AFig_A9.gph, replace)
graph export graphs/AFig_A9.pdf, replace




********************************************************************************
********************************************************************************
***TABLE 1
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

global Geot1 c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econt1 c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

global Econnlnt1 c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

****************************************
***PANEL A
****************************************
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 /*
*/ post treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatpost) nocons /*
*/ ctitle(T1_PA_c1) se bdec(3) sdec(3) rdec(3) excel replace

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 /*
*/ c.year#c.lnmfg1940 /*
*/ post treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatpost) nocons /*
*/ ctitle(T1_PA_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatpost) nocons /*
*/ ctitle(T1_PA_c3) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL B
****************************************
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 /*
*/ post sc40treatpost bc40treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
test bc40treatpost=sc40treatpost
local ttest=r(p)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40treatpost bc40treatpost) nocons /*
*/ ctitle(T1_PB_c1) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 /*
*/ c.year#c.lnmfg1940 /*
*/ post sc40treatpost bc40treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
test bc40treatpost=sc40treatpost
local ttest=r(p)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40treatpost bc40treatpost) nocons /*
*/ ctitle(T1_PB_c2) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post sc40treatpost bc40treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
test bc40treatpost=sc40treatpost
local ttest=r(p)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40treatpost bc40treatpost) nocons /*
*/ ctitle(T1_PB_c3) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

****************************************
***PANEL C
****************************************
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 /*
*/ post ltreatpost htreatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
test htreatpost=ltreatpost
local ttest=r(p)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ltreatpost htreatpost) nocons /*
*/ ctitle(T1_PC_c1) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 /*
*/ c.year#c.lnmfg1940 /*
*/ post ltreatpost htreatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
test htreatpost=ltreatpost
local ttest=r(p)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ltreatpost htreatpost) nocons /*
*/ ctitle(T1_PC_c2) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post ltreatpost htreatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
test htreatpost=ltreatpost
local ttest=r(p)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ltreatpost htreatpost) nocons /*
*/ ctitle(T1_PC_c3) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

****************************************
***BOTTOM ROWS
****************************************
*number of observations
reghdfe imr /*
*/ post treatpost /*
*/ , /*
*/ absorb(idcountyplant) cluster(county_fips) 
di e(N)

*number of county-plant pairs
reghdfe imr /*
*/ post treatpost /*
*/ , /*
*/ absorb(idcountyplant) cluster(idcountyplant) 
di e(N_clust) 

*number of counties
reghdfe imr /*
*/ post treatpost /*
*/ , /*
*/ absorb(idcountyplant) cluster(county_fips)
di e(N_clust) 


********************************************************************************
********************************************************************************
***TABLE 2
********************************************************************************
********************************************************************************
clear all
use data/imr_final_balanced.dta, clear

global Geo c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econ c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

****************************************
***PANEL A
****************************************
reghdfe imr /*
*/ cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mile) nocons /*
*/ ctitle(T2_PA_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mile) nocons /*
*/ ctitle(T2_PA_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mile) nocons /*
*/ ctitle(T2_PA_c3) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL B
****************************************
reghdfe imr /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips)
test scap1940cap30mile=bcap1940cap30mile
local ttest=r(p) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T2_PB_c1) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

reghdfe imr /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips)
test scap1940cap30mile=bcap1940cap30mile
local ttest=r(p) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T2_PB_c2) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips)
test scap1940cap30mile=bcap1940cap30mile
local ttest=r(p) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T2_PB_c3) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

****************************************
***PANEL C
****************************************
reghdfe imr /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
test cap30mileL2wlight=cap30mileH2wlight
local ttest=r(p)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T2_PC_c1) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

reghdfe imr /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
test cap30mileL2wlight=cap30mileH2wlight
local ttest=r(p)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T2_PC_c2) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
test cap30mileL2wlight=cap30mileH2wlight
local ttest=r(p)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T2_PC_c3) se bdec(3) sdec(3) rdec(3) addstat("ttest", `ttest') excel append

****************************************
***BOTTOM ROWS
****************************************
reghdfe imr /*
*/ cap30mile /*
*/ , absorb(i.county_fips i.year) cluster(county_fips) 

*number of observations
di e(N)

*number of counties
di e(N_clust) 


********************************************************************************
********************************************************************************
***TABLE 3
********************************************************************************
********************************************************************************
clear all
use data/imr_final_balanced.dta, clear

global Geo c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econ c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

****************************************
***PANEL A
****************************************
reghdfe imr /*
*/ b1950cap30mile a1950cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(b1950cap30mile a1950cap30mile) nocons /*
*/ ctitle(T3_PA_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ b1950cap30mile a1950cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(b1950cap30mile a1950cap30mile) nocons /*
*/ ctitle(T3_PA_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ b1950cap30mile a1950cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(b1950cap30mile a1950cap30mile) nocons /*
*/ ctitle(T3_PA_c3) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL B
****************************************
reghdfe imr /*
*/ sc40b50cap30mile bc40b50cap30mile sc40a50cap30mile bc40a50cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40b50cap30mile bc40b50cap30mile sc40a50cap30mile bc40a50cap30mile) nocons /*
*/ ctitle(T3_PB_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ sc40b50cap30mile bc40b50cap30mile sc40a50cap30mile bc40a50cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40b50cap30mile bc40b50cap30mile sc40a50cap30mile bc40a50cap30mile) nocons /*
*/ ctitle(T3_PB_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ sc40b50cap30mile bc40b50cap30mile sc40a50cap30mile bc40a50cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40b50cap30mile bc40b50cap30mile sc40a50cap30mile bc40a50cap30mile) nocons /*
*/ ctitle(T3_PB_c3) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL C
****************************************
reghdfe imr /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T3_PC_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T3_PC_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T3_PC_c3) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***BOTTOM ROWS
****************************************
reghdfe imr /*
*/ cap30mile /*
*/ , absorb(i.county_fips i.year) cluster(county_fips) 

*number of observations
di e(N)

*number of counties
di e(N_clust) 


********************************************************************************
********************************************************************************
***TABLE 4
********************************************************************************
********************************************************************************
clear all
use data/imr_final_balanced.dta, clear

global Geo c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Geo3 c.year#c.lat c.year#c.lon yprcpm ytavm ydda29m yddb10m

global Econ c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

reghdfe farmelec /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30mileH2wlight cap30mileL2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileH2wlight cap30mileL2wlight) nocons /*
*/ ctitle(T4_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe runwat /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30mileH2wlight cap30mileL2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileH2wlight cap30mileL2wlight) nocons /*
*/ ctitle(T4_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe elecgasstove /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30mileH2wlight cap30mileL2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileH2wlight cap30mileL2wlight) nocons /*
*/ ctitle(T4_c3) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mileH2wlight cap30mileL2wlight amdiarrcap30milelightL2w /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileH2wlight cap30mileL2wlight amdiarrcap30milelightL2w) nocons /*
*/ ctitle(T4_c4) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mileH2wlight cap30mileL2wlight cap30mileL2wlightH2wcoalstove /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileH2wlight cap30mileL2wlight cap30mileL2wlightH2wcoalstove) nocons /*
*/ ctitle(T4_c5) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***BOTTOM ROWS
****************************************
*for columns 1-3
reghdfe elecgasstove /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30mileH2wlight cap30mileL2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ , absorb(i.county_fips i.year) cluster(county_fips) 

*number of observations
di e(N)

*number of counties
di e(N_clust) 


*for columns 4-5
reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mileH2wlight cap30mileL2wlight amdiarrcap30milelightL2w /*
*/ , absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 

*number of observations
di e(N)

*number of counties
di e(N_clust) 


********************************************************************************
********************************************************************************
***TABLE 5
********************************************************************************
********************************************************************************
clear all
use data/imr_final_balanced.dta, clear

global Geo c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10
global Geo3 c.year#c.lat c.year#c.lon yprcpm ytavm ydda29m yddb10m

global Econ c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944
global Econ3nln c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

****************************************
***PANEL A
****************************************
reghdfe imr /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T5_PA_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnmvhouse_bls90 /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T5_PA_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnemp /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T5_PA_c3) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnmfg /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T5_PA_c4) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnmfgwages_bls90 /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T5_PA_c5) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnretwages_bls90 /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T5_PA_c6) se bdec(3) sdec(3) rdec(3) excel append

reghdfe pwhite /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T5_PA_c7) se bdec(3) sdec(3) rdec(3) excel append

reghdfe phschool /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons /*
*/ ctitle(T5_PA_c8) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL B
****************************************
reghdfe imr /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T5_PB_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnmvhouse_bls90 /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T5_PB_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnemp /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T5_PB_c3) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnmfg /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T5_PB_c4) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnmfgwages_bls90 /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T5_PB_c5) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnretwages_bls90 /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T5_PB_c6) se bdec(3) sdec(3) rdec(3) excel append

reghdfe pwhite /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T5_PB_c7) se bdec(3) sdec(3) rdec(3) excel append

reghdfe phschool /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(T5_PB_c8) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL C
****************************************
reghdfe imr /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T5_PC_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnmvhouse_bls90 /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T5_PC_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnemp /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T5_PC_c3) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnmfg /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T5_PC_c4) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnmfgwages_bls90 /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T5_PC_c5) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnretwages_bls90 /*
*/ $Geo3 $Econ3nln cap30mile_hydro /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T5_PC_c6) se bdec(3) sdec(3) rdec(3) excel append

reghdfe pwhite /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T5_PC_c7) se bdec(3) sdec(3) rdec(3) excel append

reghdfe phschool /*
*/ $Geo3 $Econ cap30mile_hydro /*
*/ cap30milecapdop10l cap30milecapdop10m /*
*/ if lnmrhouse_bls90~=. & N_mrhouse==3 /*
*/ [fw=births_rs], absorb(i.county_fips i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30milecapdop10l cap30milecapdop10m) nocons /*
*/ ctitle(T5_PC_c8) se bdec(3) sdec(3) rdec(3) excel append


********************************************************************************
********************************************************************************
***TABLE 6
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

global Geot1 c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econt1 c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

global Econnlnt1 c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

****************************************
***PANEL A
****************************************
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treat60post treat60postsulf /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treat60post treat60postsulf) nocons /*
*/ ctitle(T6_PA) se bdec(3) sdec(3) rdec(3) excel append


****************************************
***PANEL B
****************************************
sum sulf if treat60post==1 [fw=births_rs], detail
*                            sulf
*-------------------------------------------------------------
*      Percentiles      Smallest
* 1%     .0457082       .0181232
* 5%     .1134279       .0200577
*10%     .2511544       .0201102       Obs          56,403,408
*25%     .6640919       .0202449       Sum of Wgt.  56,403,408
*
*50%     1.350241                      Mean           1.808394
*                        Largest       Std. Dev.      1.487211
*75%     2.789671       42.22681
*90%     4.205767       46.53744       Variance       2.211796
*95%     4.594273       88.90332       Skewness       3.719853
*99%     5.009408       102.0495       Kurtosis       174.7856

local rmean_sulf = r(mean)

sum births_rs if treat60post==1, detail
*                          births_rs
*-------------------------------------------------------------
*      Percentiles      Smallest
* 1%           92             30
* 5%          148             32
*10%          196             36       Obs              29,923
*25%          324             36       Sum of Wgt.      29,923
*
*50%          582                      Mean           1884.952
*                        Largest       Std. Dev.      5464.554
*75%         1319         126482
*90%         3838         127338       Variance       2.99e+07
*95%         7676         127338       Skewness       12.21611
*99%        21798         127338       Kurtosis       230.7106

local births_mean = r(mean)
local births_county_year_obs = r(N)

sum ccapacity if treat60post==1 [fw=births_rs]
*    Variable |        Obs        Mean    Std. Dev.       Min        Max
*-------------+---------------------------------------------------------
*   ccapacity | 56,403,408    263.8316    225.8511          4       1600
local cap_mean = r(mean)

sum ccapacity if treat60post==1
*    Variable |        Obs        Mean    Std. Dev.       Min        Max
*-------------+---------------------------------------------------------
*   ccapacity |     29,923    191.7185    231.8447          4       1600
local cap_obs = r(N)

sum generation if treat60post==1 [fw=births_rs]
*    Variable |        Obs        Mean    Std. Dev.       Min        Max
*-------------+---------------------------------------------------------
*  generation | 49,211,842    1599.874    1438.076          0    11768.5
local gen_mean = r(mean)

sum generation if treat60post==1
*    Variable |        Obs        Mean    Std. Dev.       Min        Max
*-------------+---------------------------------------------------------
*  generation |     25,881    1176.903    1640.595          0    11768.5
local gen_obs = r(N)


merge m:1 county_fips using data/dist_newhydro_after1962.dta,
keep if _merge==3
drop _merge

bysort plant_id treat: egen mindist_coal = min(dist_miles)
replace mindist_coal =. if treat==0
replace mindist_coal = (dist_miles == mindist_coal)
replace mindist_coal =. if treat==0

gen ddist_newhydro_aux = dist_newhydro - dist_miles if mindist_coal==1
bysort plant_id treat: egen ddist_newhydro = mean(ddist_newhydro_aux)
replace ddist_newhydro =. if treat==0

sort plant_id county_fips year
order idcountyplant-dist_miles mindist_coal dist_newhydro ddist_newhydro treat

sum ddist_newhydro [fw=births_rs], detail
*                       ddist_newhydro
*-------------------------------------------------------------
*      Percentiles      Smallest
* 1%    -16.26138      -16.26138
* 5%     17.52102      -16.26138
*10%     40.78881      -16.26138       Obs          78,767,856
*25%     77.43867      -16.26138       Sum of Wgt.  78,767,856
*
*50%     153.3406                      Mean           173.7153
*                        Largest       Std. Dev.      108.8488
*75%     252.9309       610.2101
*90%     321.7703       610.2101       Variance       11848.06
*95%     369.6405       610.2101       Skewness       .4713779
*99%     434.8539       610.2101       Kurtosis       2.579424
*250 miles is approximately the 75pctile, which is what hydro would 
*make up for coal if we includes pumped storage

bysort plant_id treat: gen nplant = _n
replace nplant =. if treat==0
sum ddist_newhydro if ddist_newhydro<=250 & nplant==1 [fw=births_rs], detail
*                       ddist_newhydro
*-------------------------------------------------------------
*      Percentiles      Smallest
* 1%    -16.26138      -16.26138
* 5%     17.34225      -12.23246
*10%     38.38426       8.161737       Obs             624,219
*25%     76.41632       12.77319       Sum of Wgt.     624,219
*
*50%      129.483                      Mean           127.1616
*                        Largest       Std. Dev.      64.53809
*75%     185.7573       241.7923
*90%      207.209        244.806       Variance       4165.165
*95%     212.1309       246.8701       Skewness      -.3473706
*99%     237.9106       247.1189       Kurtosis       2.162483

local rmean_tlines_hydro = r(mean)

sum ddist_newhydro if ddist_newhydro<=250 & nplant==1
*    Variable |        Obs        Mean    Std. Dev.       Min        Max
*-------------+---------------------------------------------------------
*ddist_newh~o |        194    125.5211    68.88271  -16.26138   247.1189
local tlines_county_obs_hydro = r(N)

sum generation if treat60post==1 & ddist_newhydro<=250 [fw=births_rs]
*    Variable |        Obs        Mean    Std. Dev.       Min        Max
*-------------+---------------------------------------------------------
*  generation | 25,760,885    1578.082    1252.657          0    11768.5
local gen_mean_hydro = r(mean)

sum generation if treat60post==1 & ddist_newhydro<=250
*    Variable |        Obs        Mean    Std. Dev.       Min        Max
*-------------+---------------------------------------------------------
*  generation |      7,633    1365.331    1643.815          0    11768.5
local gen_obs_hydro = r(N)

di (`gen_mean_hydro' * `gen_obs_hydro' * 0.01 * (0.041*2.5))/25
*$493.86543 million (1990 USD) (transmission losses)
local cost_tlines_newhydro = [(`rmean_tlines_hydro' * `tlines_county_obs_hydro' * 0.32464194)/40] /*
*/ + [(`gen_mean_hydro' * `gen_obs_hydro' * 0.01 * (0.041*2.5))/25]
di `cost_tlines_newhydro'
*$694.86588 million (1990 USD)
*maximum transmission voltages in the United States in 1954: 345 kv (FPC_1964_The 1964 national power survey, p.14)
*representative investment per mile of 345 kv transmission line, including right-of-way: 
*$77,000 (FPC_1964_The 1964 national power survey, p.151, 1964 USD) -- $324,641.94 (1990 USD) or $0.32464194 million
*electricity prices 1960: $0.018cents (2005 USD, https://www.eia.gov/totalenergy/data/annual/showtext.php?t=ptb0810) -- $0.01 (1990 USD)
*transmission losses per 100 miles (4.1 percent)

sum sulf if treat60post==1 & ddist_newhydro<=250 [fw=births_rs], detail
*                            sulf
*-------------------------------------------------------------
*      Percentiles      Smallest
* 1%      .043188       .0246564
* 5%      .228789       .0262609
*10%     .3123894       .0289283       Obs          23,813,851
*25%     .7936416       .0289283       Sum of Wgt.  23,813,851
*
*50%     1.655592                      Mean           2.093757
*                        Largest       Std. Dev.      1.571961
*75%     3.371047        5.50089
*90%     4.317475       9.530711       Variance        2.47106
*95%     4.829809       88.90332       Skewness       5.543063
*99%     5.109356       102.0495       Kurtosis       302.3458

local rmean_sulf_hydro = r(mean)

sum births_rs if treat60post==1 & ddist_newhydro<=250, detail
*                          births_rs
*-------------------------------------------------------------
*      Percentiles      Smallest
* 1%          112             40
* 5%          176             42
*10%          240             54       Obs               7,031
*25%          410             56       Sum of Wgt.       7,031
*
*50%          890                      Mean           3386.979
*                        Largest       Std. Dev.       6101.59
*75%         3394          46586
*90%        10164          46586       Variance       3.72e+07
*95%        15576          46586       Skewness       3.558306
*99%        26388          47915       Kurtosis       19.37691

local births_mean_hydro = r(mean)
local births_county_year_obs_hydro = r(N)

****************************************
***PANEL B
****************************************
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treat60post treat60postsulf /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips)
local sulfred_stack = 95
local sulfred_newhydro = 100
local sulfred_bag = 99
local affplt_stack = 270
local affplt_newhydro = 194
local affplt_bag = 270
local cnterf_stack = [(_b[treat60postsulf] * `rmean_sulf' *0.95) * ((`births_mean' * `births_county_year_obs') /1000)] /25
local cnterf_newhydro = [(_b[treat60postsulf] * `rmean_sulf_hydro') * ((`births_mean_hydro' * `births_county_year_obs_hydro') /1000)] /25
local cnterf_bag = [(_b[treat60postsulf] * `rmean_sulf' *0.99) * ((`births_mean' * `births_county_year_obs') /1000)] /25
local costplife_stack = [2.73 * [(`cap_mean' * 1000 * `cap_obs' * 10)/(40 * 25) + (`gen_mean' * 1000000 * `gen_obs' * 0.00015)/25]] / `cnterf_stack'
local costplife_newhydro = (`cost_tlines_newhydro'*1000000) / `cnterf_newhydro'
local costplife_baglbound = [(270 * 110000) + (270 * 165000 * 3.70)] / `cnterf_bag'
local costplife_bagubound = [(270 * 750000) + (270 * 198000 * 3.70)] / `cnterf_bag'
*1 dollar in 1974 is equivalent to 2.73 dollars in 1990
*capacity is measured in megawatts -- 1 megawatt = 1000 kilowatts
*generation is measured in millions of kilowatt-hours
*1 mill = 0.001 dollar -- a mill is equal to 1/1,000 of a U.S. dollar, or 1/10 of one cent 
*There were two primary costs associated with baghouses: installation costs and fly ash disposal. 
*For a typical large power plant the installation costs, annualized over the expected 15-year lifespan, 
*could range from $110,000 to $750,000 (1990 USD) per year depending on the desired airflow (USHEW, 1969). 
*The cost of fly ash disposal for electric utilities was $3.70 per ton, and the typical power plant in 
*the sample produced between 165,000 and 198,000 tons of fly ash per year. Thus the annual cost of pollution 
*abatement ranged from $720,000 to $1.48 million per plant.
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treat60post treat60postsulf) nocons /*
*/ ctitle(T6_PB) se bdec(3) sdec(3) rdec(3) addstat("sulfred_stack", `sulfred_stack', "affplt_stack", `affplt_stack', /*
*/ "cnterf_stack", `cnterf_stack', "costplife_stack", `costplife_stack', "sulfred_newhydro", `sulfred_newhydro', "affplt_newhydro", /*
*/ `affplt_newhydro', "cnterf_newhydro", `cnterf_newhydro', "costplife_newhydro", `costplife_newhydro', "sulfred_bag", `sulfred_bag', /*
*/ "affplt_bag", `affplt_bag', "cnterf_bag", `cnterf_bag', "costplife_baglbound", `costplife_baglbound', "costplife_bagubound", /*
*/ `costplife_bagubound') excel append
*As explained in Appendix B.3.3, we approximate the number of infant lives saved and cost per life saved, and take the midpoint from 
*the cost per life saved between a lower bound and an upper bound for the counterfactual for baghouses.


********************************************************************************
********************************************************************************
***APPENDIX TABLE A.1
********************************************************************************
********************************************************************************
*compilation of information from previous studies cited there


********************************************************************************
********************************************************************************
***APPENDIX TABLE A.2
********************************************************************************
********************************************************************************
clear all
use data/tspEPA_1957_62_semibalanced.dta, clear
*semi-balanced: at least 4 out of 6 obs (or at least two thirds of the obs)
*these annual summary data on pollution were provided by EPA through a FOIA request

global Geo c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

reg tsp i.state_fips#i.year /*
*/ $Geo /*
*/ cap30mile /*
*/ , cluster(county_fips) 
local n_counties = e(N_clust)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mile) nocons /*
*/ ctitle(ATA2_c1) se bdec(3) sdec(3) rdec(3) addstat("n_counties", `n_counties') excel append

reg tsp i.state_fips#i.year /*
*/ $Geo /*
*/ cap50mile /*
*/ , cluster(county_fips) 
local n_counties = e(N_clust)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap50mile) nocons /*
*/ ctitle(ATA2_c2) se bdec(3) sdec(3) rdec(3) addstat("n_counties", `n_counties') excel append

****************************************
***BOTTOM ROWS
****************************************
*Mean dep var (TSP) -- 1957
sum tsp if year==1957
local avg_tsp_1957 = r(mean)
di `avg_tsp_1957'

*Mean dep var (TSP) -- 1962
sum tsp if year==1962
local avg_tsp_1962 = r(mean)
di `avg_tsp_1962'


********************************************************************************
********************************************************************************
***APPENDIX TABLE A.3
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

*creating intermediate variables
gen treat_bigsmall = 1 if treat==1 & bcap1940==1
replace treat_bigsmall = 2 if treat==1 & scap1940==1

*adjusting units of variables
replace pop = pop/1000
replace spopurb = spopurb*100
replace emp = emp/1000
replace smfg = smfg*100
replace f_coalq = f_coalq/100
replace cap30mile_hydro = cap30mile_hydro*100
*cap30mile_hydro was measured in 100s of MWs

*generating access to electricity based on percent of
*households with lighting
gen elec = light*100
replace elec = 100 if year==1960


****************************************
***PANEL A
****************************************
*number of plants (for big vs. small cap1940, and total)
sort idcountyplant plant_id county_fips year
bysort treat plant_id: gen n_plant = _n
tab treat_bigsmall if n_plant==1

*initial year of operation
table control if year==1940 [fw=births_rs], c(mean cinityropr) format(%12.0f) row
table treat_bigsmall if year==1940 [fw=births_rs], c(mean cinityropr) format(%12.0f)

*capacity
table control if post>=0 [fw=births_rs], c(mean ccapacity) format(%12.1f) row
table treat_bigsmall if post>=0 [fw=births_rs], c(mean ccapacity) format(%12.1f)

*annual coal consumption
table control [fw=births_rs], c(mean f_coalq) format(%12.1f) row
table treat_bigsmall [fw=births_rs], c(mean f_coalq) format(%12.1f) row


****************************************
***PANEL B
****************************************
*infant mortality rate
table control [fw=births_rs], c(mean imr) format(%12.1f) row
table treat_bigsmall [fw=births_rs], c(mean imr) format(%12.1f)

*distance to power plant
table control [fw=births_rs], c(mean dist_miles) format(%12.1f) row
table treat_bigsmall [fw=births_rs], c(mean dist_miles) format(%12.1f)

*hydroelectric capacity
table control [fw=births_rs], c(mean cap30mile_hydro) format(%12.0f) row
table treat_bigsmall [fw=births_rs], c(mean cap30mile_hydro) format(%12.0f)

*baseline characteristics
*employment
table control if year==1940 [fw=births_rs], c(mean emp) format(%12.0f) row
table treat_bigsmall if year==1940 [fw=births_rs], c(mean emp) format(%12.0f)

*% manufacturing employment
table control if year==1940 [fw=births_rs], c(mean smfg) format(%12.1f) row
table treat_bigsmall if year==1940 [fw=births_rs], c(mean smfg) format(%12.1f) row

*population
table control if year==1940 [fw=births_rs], c(mean pop) format(%12.0f) row
table treat_bigsmall if year==1940 [fw=births_rs], c(mean pop) format(%12.0f)

*% urban
table control if year==1940 [fw=births_rs], c(mean spopurb) format(%12.1f) row
table treat_bigsmall if year==1940 [fw=births_rs], c(mean spopurb) format(%12.1f) row

*% households with electricity
table control if year==1940 [fw=births_rs], c(mean elec) format(%12.1f) row
table treat_bigsmall if year==1940 [fw=births_rs], c(mean elec) format(%12.1f) row

*railroad mileage
table control if year==1940 [fw=births_rs], c(mean railroads) format(%12.1f) row
table treat_bigsmall if year==1940 [fw=births_rs], c(mean railroads) format(%12.1f) row

*predicted interstate highway
table control if year==1940 [fw=births_rs], c(mean inst1944) format(%12.2f) row
table treat_bigsmall if year==1940 [fw=births_rs], c(mean inst1944) format(%12.2f) row


****************************************
***BOTTOM ROWS
****************************************
*number of counties
sort idcountyplant plant_id county_fips year
bysort county_fips: gen n_county1 = _n
tab control if n_county1==1
*number of counties for big vs small cap1940
sort idcountyplant plant_id county_fips year
bysort treat county_fips: gen n_county2 = _n
tab treat_bigsmall if n_county2==1

*number of county-plant pairs
sort idcountyplant plant_id county_fips year
bysort idcountyplant: gen n_countyplant = _n
tab control if n_countyplant==1
*number of county-plant pairs for big vs small cap1940
tab treat_bigsmall if n_countyplant==1

*number of observations
tab control
*number of observations for big vs small cap1940
tab treat_bigsmall


********************************************************************************
********************************************************************************
***APPENDIX TABLE A.4
********************************************************************************
********************************************************************************
clear all
use data/imr_final_balanced.dta, clear

*Adjusting units for summary statistics
replace pop = pop/1000
replace emp = emp/1000
replace mfg = mfg/1000
replace smfg = smfg*100
replace light = light*100
replace spopurb = spopurb*100
replace swhite = swhite*100
replace hschool = hschool*100

gen ccap1940= 1 if bcap1940==1
replace ccap1940 = 2 if scap1940==1

****************************************
***PANEL A
****************************************
*Infant mortality rate -- Mean
table ccap1940 [fw=births_rs], c(mean imr) format(%12.1f) row

*Infant mortality rate -- Change, 1962-1938
sort county_fips year
gen imr_ch = imr - imr[_n-24]
replace imr_ch = . if year~=1962
table ccap1940 [fw=births_rs], c(mean imr_ch) format(%12.2f) row

*Median dwelling value, 1990$
table ccap1940 [fw=births_rs], c(mean mvhouse_bls90) format(%12.0f) row

*Manufacturing payroll per worker
table ccap1940 [fw=births_rs], c(mean mfgwages_bls90) format(%12.1f) row

*Retail payroll per worker
table ccap1940 [fw=births_rs], c(mean retwages_bls90) format(%12.1f) row

*% White
table ccap1940 [fw=births_rs], c(mean swhite) format(%12.1f) row

*% High School (age 25+)
table ccap1940 [fw=births_rs], c(mean hschool) format(%12.1f) row

****************************************
***PANEL B
****************************************
*Coal capacity <30 miles (100 MWs) -- Mean
table ccap1940 [fw=births_rs], c(mean cap30mile) format(%12.2f) row

*Coal capacity <30 miles (100 MWs) -- Change, 1962-1938
sort county_fips year
gen cap30mile_ch = cap30mile - cap30mile[_n-24]
replace cap30mile_ch = . if year~=1962
table ccap1940 [fw=births_rs], c(mean cap30mile_ch) format(%12.2f) row

*Coal consumption <30 miles (100K Tons) -- Mean
table ccap1940 [fw=births_rs], c(mean coal30mile) format(%12.2f) row

*Coal consumption <30 miles (100K Tons) -- Change, 1962-1938
sort county_fips year
gen coal30mile_ch = coal30mile - coal30mile[_n-24]
replace coal30mile_ch = . if year~=1962
table ccap1940 [fw=births_rs], c(mean coal30mile_ch) format(%12.2f) row

*Hydro capacity <30 miles (100 MWs) -- Mean
table ccap1940 [fw=births_rs], c(mean cap30mile_hydro) format(%12.2f) row

*Hydro capacity <30 miles (100 MWs) -- Change, 1962-1938
sort county_fips year
gen cap30mile_hydro_ch = cap30mile_hydro - cap30mile_hydro[_n-24]
replace cap30mile_hydro_ch = . if year~=1962
table ccap1940 [fw=births_rs], c(mean cap30mile_hydro_ch) format(%12.2f) row

****************************************
***PANEL C
****************************************
*Population (1,000s)
table ccap1940 if year==1940 [fw=births_rs], c(mean pop) format(%12.0f) row

*% Urban
table ccap1940 if year==1940 [fw=births_rs], c(mean spopurb) format(%12.1f) row

*Employment (1,000s)
table ccap1940 if year==1940 [fw=births_rs], c(mean emp) format(%12.0f) row

*% Manufacturing Employment
table ccap1940 if year==1940 [fw=births_rs], c(mean smfg) format(%12.1f) row

*% Households with Electricity 
table ccap1940 if year==1940 [fw=births_rs], c(mean light) format(%12.1f) row

*Mileage of Railroads, 1911 
table ccap1940 if year==1940 [fw=births_rs], c(mean railroads) format(%12.1f) row

*Predicted Interstate Highway, 1944
table ccap1940 if year==1940 [fw=births_rs], c(mean inst1944) format(%12.2f) row

****************************************
***BOTTOM ROW
****************************************
*Number of Counties
table ccap1940 if year==1962, format(%12.0f) row


********************************************************************************
********************************************************************************
***APPENDIX TABLE A.5
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

global Geot1 c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econt1 c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

global Econnlnt1 c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

****************************************
***PANEL A
****************************************
*Baseline estimates
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatpost) nocons /*
*/ ctitle(ATA5_PA_c1) se bdec(3) sdec(3) rdec(3) excel append

*Weight by females age 15-44
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treatpost /*
*/ [fw=popf15_44], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatpost) nocons /*
*/ ctitle(ATA5_PA_c2) se bdec(3) sdec(3) rdec(3) excel append

*Omit counties -- Treated by multiple plants
capture drop ncy
bysort county_fips year: gen ncy = _n
capture drop N
bysort county_fips treat: gen N = _N

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treatpost /*
*/ if ((treat==1 & N==25) | (treat==0 & ncy==1)) [fw=births_rs], /*
*/ absorb(county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatpost) nocons /*
*/ ctitle(ATA5_PA_c3) se bdec(3) sdec(3) rdec(3) excel append

*Omit counties -- 30-60 miles from plant
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treatpost /*
*/ [fw=births_rs] if (dist_miles<=30 |dist_miles>=60), /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatpost) nocons /*
*/ ctitle(ATA5_PA_c4) se bdec(3) sdec(3) rdec(3) excel append

*Alternate treatment radii -- <20 miles from plant
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treat20post /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treat20post) nocons /*
*/ ctitle(ATA5_PA_c5) se bdec(3) sdec(3) rdec(3) excel append

*Alternate treatment radii -- <40 miles from plant
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treat40post /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treat40post) nocons /*
*/ ctitle(ATA5_PA_c6) se bdec(3) sdec(3) rdec(3) excel append

*Log infant mortality rate
capture gen lnimr = ln(imr)
reghdfe lnimr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatpost) nocons /*
*/ ctitle(ATA5_PA_c7) se bdec(3) sdec(3) rdec(3) excel append

*Effects by plant size
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post btreatpost streatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(btreatpost streatpost) nocons /*
*/ ctitle(ATA5_PA_c8) se bdec(3) sdec(3) rdec(3) excel append

*Effects by wind direction
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treatdown_post treatup_post /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatdown_post treatup_post) nocons /*
*/ ctitle(ATA5_PA_c9) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL B
****************************************
*Baseline estimates
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post sc40treatpost bc40treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40treatpost bc40treatpost) nocons /*
*/ ctitle(ATA5_PB_c1) se bdec(3) sdec(3) rdec(3) excel append

*Weight by females age 15-44
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post sc40treatpost bc40treatpost /*
*/ [fw=popf15_44], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40treatpost bc40treatpost) nocons /*
*/ ctitle(ATA5_PB_c2) se bdec(3) sdec(3) rdec(3) excel append

*Omit counties -- Treated by multiple plants
capture drop ncy
bysort county_fips year: gen ncy = _n
capture drop N
bysort county_fips treat: gen N = _N

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post sc40treatpost bc40treatpost /*
*/ if ((treat==1 & N==25) | (treat==0 & ncy==1)) [fw=births_rs], /*
*/ absorb(county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40treatpost bc40treatpost) nocons /*
*/ ctitle(ATA5_PB_c3) se bdec(3) sdec(3) rdec(3) excel append

*Omit counties -- 30-60 miles from plant
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post sc40treatpost bc40treatpost /*
*/ [fw=births_rs] if (dist_miles<=30 |dist_miles>=60), /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40treatpost bc40treatpost) nocons /*
*/ ctitle(ATA5_PB_c4) se bdec(3) sdec(3) rdec(3) excel append

*Alternate treatment radii -- <20 miles from plant
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post bc40treat20post sc40treat20post /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(bc40treat20post sc40treat20post) nocons /*
*/ ctitle(ATA5_PB_c5) se bdec(3) sdec(3) rdec(3) excel append

*Alternate treatment radii -- <40 miles from plant
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post bc40treat40post sc40treat40post /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(bc40treat40post sc40treat40post) nocons /*
*/ ctitle(ATA5_PB_c6) se bdec(3) sdec(3) rdec(3) excel append

*Log infant mortality rate
capture gen lnimr = ln(imr)
reghdfe lnimr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post sc40treatpost bc40treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40treatpost bc40treatpost) nocons /*
*/ ctitle(ATA5_PB_c7) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL C
****************************************
*Baseline estimates
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post ltreatpost htreatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ltreatpost htreatpost) nocons /*
*/ ctitle(ATA5_PC_c1) se bdec(3) sdec(3) rdec(3) excel append

*Weight by females age 15-44
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post ltreatpost htreatpost /*
*/ [fw=popf15_44], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ltreatpost htreatpost) nocons /*
*/ ctitle(ATA5_PC_c2) se bdec(3) sdec(3) rdec(3) excel append

*Omit counties -- Treated by multiple plants
capture drop ncy
bysort county_fips year: gen ncy = _n
capture drop N
bysort county_fips treat: gen N = _N

reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post ltreatpost htreatpost /*
*/ if ((treat==1 & N==25) | (treat==0 & ncy==1)) [fw=births_rs], /*
*/ absorb(county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ltreatpost htreatpost) nocons /*
*/ ctitle(ATA5_PC_c3) se bdec(3) sdec(3) rdec(3) excel append

*Omit counties -- 30-60 miles from plant
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post ltreatpost htreatpost /*
*/ [fw=births_rs] if (dist_miles<=30 |dist_miles>=60), /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ltreatpost htreatpost) nocons /*
*/ ctitle(ATA5_PC_c4) se bdec(3) sdec(3) rdec(3) excel append

*Alternate treatment radii -- <20 miles from plant
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post htreat20post ltreat20post /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(htreat20post ltreat20post) nocons /*
*/ ctitle(ATA5_PC_c5) se bdec(3) sdec(3) rdec(3) excel append

*Alternate treatment radii -- <40 miles from plant
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post htreat40post ltreat40post /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(htreat40post ltreat40post) nocons /*
*/ ctitle(ATA5_PC_c6) se bdec(3) sdec(3) rdec(3) excel append

*Log infant mortality rate
capture gen lnimr = ln(imr)
reghdfe lnimr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post ltreatpost htreatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ltreatpost htreatpost) nocons /*
*/ ctitle(ATA5_PC_c7) se bdec(3) sdec(3) rdec(3) excel append


********************************************************************************
********************************************************************************
***APPENDIX TABLE A.6
********************************************************************************
********************************************************************************
clear all
use data/eventstudy_treat30miles_90_11_7.dta, clear

global Geot1 c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10

global Econt1 c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944

global Econnlnt1 c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

****************************************
***PANEL A
****************************************
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
local r2_oster = `e(r2)'*1.3
di `r2_oster'
psacalc2 beta treatpost, rmax(`r2_oster')
local beta1 = r(beta)
psacalc2 delta treatpost, rmax(`r2_oster')
local delta1 = r(delta)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(treatpost) nocons /*
*/ ctitle(ATA6_PA) se bdec(3) sdec(3) rdec(3) /*
*/ addstat("r2_oster", `r2_oster', "delta1", `delta1', "beta1", `beta1') excel append

****************************************
***PANEL B
****************************************
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post sc40treatpost bc40treatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
local r2_oster = `e(r2)'*1.3
di `r2_oster'
psacalc2 beta bc40treatpost, rmax(`r2_oster')
local beta1 = r(beta)
psacalc2 delta bc40treatpost, rmax(`r2_oster')
local delta1 = r(delta)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(sc40treatpost bc40treatpost) nocons /*
*/ ctitle(ATA6_PB_c3) se bdec(3) sdec(3) rdec(3) /*
*/ addstat("r2_oster", `r2_oster', "beta1", `beta1', "delta1", `delta1') excel append

****************************************
***PANEL C
****************************************
reghdfe imr /*
*/ c.year#c.dist_miles ccapacity /*
*/ $Geot1 $Econt1 /*
*/ c.year#c.light1940 cap30mile_hydro /*
*/ post ltreatpost htreatpost /*
*/ [fw=births_rs], /*
*/ absorb(idcountyplant i.state_fips#i.year) cluster(county_fips) 
local r2_oster = `e(r2)'*1.3
di `r2_oster'
psacalc2 beta htreatpost, rmax(`r2_oster')
local beta1 = r(beta)
psacalc2 delta htreatpost, rmax(`r2_oster')
local delta1 = r(delta)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ltreatpost htreatpost) nocons /*
*/ ctitle(ATA6_PC) se bdec(3) sdec(3) rdec(3) /*
*/ addstat("r2_oster", `r2_oster', "beta1", `beta1', "delta1", `delta1') excel append


********************************************************************************
********************************************************************************
***APPENDIX TABLE A.7
********************************************************************************
********************************************************************************
clear all
use data/imr_final_balanced.dta, clear

xtset state_fips

****************************************
***PANEL A
****************************************
*log(total employment)
xtreg dcap30mile62_38 lnemp if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(lnemp) nocons /*
*/ ctitle(ATA7_PA_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 lnemp if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(lnemp) nocons /*
*/ ctitle(ATA7_PA_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dlnemp if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dlnemp) nocons /*
*/ ctitle(ATA7_PA_c3) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dlnemp if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dlnemp) nocons /*
*/ ctitle(ATA7_PA_c4) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

*manufacturing employment percentage
xtreg dcap30mile62_38 pmfg if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(pmfg) nocons /*
*/ ctitle(ATA7_PA_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 pmfg if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(pmfg) nocons /*
*/ ctitle(ATA7_PA_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dpmfg if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dpmfg) nocons /*
*/ ctitle(ATA7_PA_c3) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dpmfg if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dpmfg) nocons /*
*/ ctitle(ATA7_PA_c4) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

*manufacturing payroll per worker
xtreg dcap30mile62_38 mfgwages_bls90 if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(mfgwages_bls90) nocons /*
*/ ctitle(ATA7_PA_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 mfgwages_bls90 if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(mfgwages_bls90) nocons /*
*/ ctitle(ATA7_PA_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dmfgwages_bls90 if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dmfgwages_bls90) nocons /*
*/ ctitle(ATA7_PA_c3) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dmfgwages_bls90 if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dmfgwages_bls90) nocons /*
*/ ctitle(ATA7_PA_c4) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

*retail payroll per worker
xtreg dcap30mile62_38 retwages_bls90 if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(retwages_bls90) nocons /*
*/ ctitle(ATA7_PA_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 retwages_bls90 if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(retwages_bls90) nocons /*
*/ ctitle(ATA7_PA_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dretwages_bls90 if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dretwages_bls90) nocons /*
*/ ctitle(ATA7_PA_c3) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dretwages_bls90 if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dretwages_bls90) nocons /*
*/ ctitle(ATA7_PA_c4) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

*railroad miles, 1911
xtreg dcap30mile62_38 railroads if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(railroads) nocons /*
*/ ctitle(ATA7_PA_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 railroads if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(railroads) nocons /*
*/ ctitle(ATA7_PA_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

*predicted interstate highway, 1944
xtreg dcap30mile62_38 inst1944 if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(inst1944) nocons /*
*/ ctitle(ATA7_PA_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 inst1944 if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(inst1944) nocons /*
*/ ctitle(ATA7_PA_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append


****************************************
***PANEL B
****************************************
*infant mortality rate
xtreg dcap30mile62_38 imr if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(imr) nocons /*
*/ ctitle(ATA7_PB_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 imr if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(imr) nocons /*
*/ ctitle(ATA7_PB_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dimr if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dimr) nocons /*
*/ ctitle(ATA7_PB_c3) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dimr if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dimr) nocons /*
*/ ctitle(ATA7_PB_c4) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

*percent urban
xtreg dcap30mile62_38 ppopurb if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ppopurb) nocons /*
*/ ctitle(ATA7_PB_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 ppopurb if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(ppopurb) nocons /*
*/ ctitle(ATA7_PB_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dppopurb if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dppopurb) nocons /*
*/ ctitle(ATA7_PB_c3) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dppopurb if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dppopurb) nocons /*
*/ ctitle(ATA7_PB_c4) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

*percent white
xtreg dcap30mile62_38 pwhite if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(pwhite) nocons /*
*/ ctitle(ATA7_PB_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 pwhite if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(pwhite) nocons /*
*/ ctitle(ATA7_PB_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dpwhite if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dpwhite) nocons /*
*/ ctitle(ATA7_PB_c3) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dpwhite if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dpwhite) nocons /*
*/ ctitle(ATA7_PB_c4) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

*log(median dwelling rent)
xtreg dcap30mile62_38 lnmrhouse_bls90 if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(lnmrhouse_bls90) nocons /*
*/ ctitle(ATA7_PB_c1) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 lnmrhouse_bls90 if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(lnmrhouse_bls90) nocons /*
*/ ctitle(ATA7_PB_c2) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dlnmrhouse_bls90 if year==1940 & bcap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dlnmrhouse_bls90) nocons /*
*/ ctitle(ATA7_PB_c3) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append

xtreg dcap30mile62_38 dlnmrhouse_bls90 if year==1940 & scap1940==1, fe cluster(state_fips)
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(dlnmrhouse_bls90) nocons /*
*/ ctitle(ATA7_PB_c4) se bdec(4) sdec(4) rdec(3) addstat("R2W",`e(r2_w)') excel append


********************************************************************************
********************************************************************************
***APPENDIX TABLE A.8
********************************************************************************
********************************************************************************
clear all
use data/imr_final_balanced.dta, clear

global Geo c.year#c.laty c.year#c.lony yprcp ytav ydda29 yddb10
global Geo3 c.year#c.lat c.year#c.lon yprcpm ytavm ydda29m yddb10m

global Econ c.year#c.lnpop1940 c.year#c.lnemp1940 c.year#c.lnmfg1940 c.year#c.railroads c.year#c.inst1944
global Econ3nln c.year#c.pop1940 c.year#c.emp1940 c.year#c.mfg1940 c.year#c.railroads c.year#c.inst1944

****************************************
***PANEL A
****************************************
reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mile /*
*/ if dist30_1960<=90 [fw=births_rs], /*
*/ absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mile) nocons /*
*/ ctitle(ATA8_PA_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mile /*
*/ if (cap30mile_1962>0 & cap30mile_1962~=.) [fw=births_rs], /*
*/ absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mile) nocons /*
*/ ctitle(ATA8_PA_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap50mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap50mile) nocons /*
*/ ctitle(ATA8_PA_c3) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap100mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap100mile) nocons /*
*/ ctitle(ATA8_PA_c4) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnimr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mile) nocons /*
*/ ctitle(ATA8_PA_c5) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ /*
*/ cap30mile_hydro /*
*/ if n0==25 [fw=births_rs], /*
*/ absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mile_hydro) nocons /*
*/ ctitle(ATA8_PA_c6) se bdec(3) sdec(3) rdec(3) excel append
*n0:number of obs before coal plant openings
*if n0=25, then there's no coal plant in the county

reghdfe imr /*
*/ $Geo $Econ /*
*/ cap50mile_hydro /*
*/ if n0==25 [fw=births_rs], /*
*/ absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap50mile_hydro) nocons /*
*/ ctitle(ATA8_PA_c7) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL B
****************************************
reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile  /*
*/ if dist30_1960<=90 [fw=births_rs], /*
*/ absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons  /*
*/ ctitle(ATA8_PB_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile  /*
*/ if (cap30mile_1962>0 & cap30mile_1962~=.) [fw=births_rs], /*
*/ absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons  /*
*/ ctitle(ATA8_PB_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ scap1940cap50mile bcap1940cap50mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap50mile bcap1940cap50mile) nocons  /*
*/ ctitle(ATA8_PB_c3) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ scap1940cap100mile bcap1940cap100mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap100mile bcap1940cap100mile) nocons  /*
*/ ctitle(ATA8_PB_c4) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnimr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ scap1940cap30mile bcap1940cap30mile /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(scap1940cap30mile bcap1940cap30mile) nocons  /*
*/ ctitle(ATA8_PB_c5) se bdec(3) sdec(3) rdec(3) excel append

****************************************
***PANEL C
****************************************
reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if dist30_1960<=90 [fw=births_rs], /*
*/ absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(ATA8_PC_c1) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ if (cap30mile_1962>0 & cap30mile_1962~=.) [fw=births_rs], /*
*/ absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(ATA8_PC_c2) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap50mileL2wlight cap50mileH2wlight /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap50mileL2wlight cap50mileH2wlight) nocons /*
*/ ctitle(ATA8_PC_c3) se bdec(3) sdec(3) rdec(3) excel append

reghdfe imr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap100mileL2wlight cap100mileH2wlight /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap100mileL2wlight cap100mileH2wlight) nocons /*
*/ ctitle(ATA8_PC_c4) se bdec(3) sdec(3) rdec(3) excel append

reghdfe lnimr /*
*/ $Geo $Econ cap30mile_hydro /*
*/ cap30mileL2wlight cap30mileH2wlight /*
*/ [fw=births_rs], absorb(i.county_fips i.state_fips#i.year) cluster(county_fips) 
outreg2 /*
*/ using logfiles/Canary_output, /*
*/ keep(cap30mileL2wlight cap30mileH2wlight) nocons /*
*/ ctitle(ATA8_PC_c5) se bdec(3) sdec(3) rdec(3) excel append



log close
